package com.xzlf.controller;

import com.xzlf.dto.RequestDTO;
import com.xzlf.dto.ResultDTO;
import com.xzlf.service.AsyncSendService;
import com.xzlf.service.SyncSendService;
import com.xzlf.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class AsyncRequestController {

    @Autowired
    private AsyncSendService asyncSendService;

    @PostMapping("/async")
    public R sync(@RequestBody RequestDTO requestDTO) {
        asyncSendService.send(requestDTO);
        return R.ok();
    }
    @PostMapping("/asyncUp")
    public R syncUp(@RequestBody RequestDTO requestDTO) {
        asyncSendService.up(requestDTO);
        return R.ok();
    }

    @GetMapping("/getAsyncResult/{requestId}")
    public R sync(@PathVariable String requestId) {
        return R.ok(asyncSendService.getResult(requestId));
    }

}
